﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Keras;
using Keras.Models;
using Keras.Helper;

namespace KerasHelperNet
{
    public partial class TestForm : Form
    {
        public TestForm()
        {
            InitializeComponent();
            this.KearsCLRTest2();
        }

        /// <summary>
        /// https://github.com/SciSharp/Keras.NET
        /// </summary>
        private void KerasNetTest()
        {
            //读取模型
            KerasModel.GetBaseModel(@"G:\博士论文\钢筋混凝土柱补充试验\Python\HyperParameter\Activations-Adam\relu\0\AUDMColumnH0.h5");
            //构造参数
            var paramList = new List<double>
            {
               0.46153846200000004,0.152727273,0.89749875,0.035333333,
            };
            //初始化参数
            var inputParam = new InputParamSet();
            //添加数据
            for (int i = 1; i <= 400000; i++)
                inputParam.Add(paramList);
            //循环求解
            var y = inputParam.Predict();
        }

        /// <summary>
        /// https://github.com/gosha20777/keras2cpp
        /// https://gitee.com/civilwilson/KerasHelper
        /// </summary>
        private void KerasCLRTest()
        {
            var kerasModel = new KerasEnsembleNet(@"G:\博士论文\钢筋混凝土柱补充试验\Python\ModelVS\tEnsembleSke", 2);
            //构造参数
            var paramList = new List<double>
            {
                 0.462, 0.153, 0.897
            };
            //循环预测
            for (int i = 1; i <= 100; i++)
            {
                var y = kerasModel.Predict(paramList);
            }
        }

        private void KearsCLRTest2()
        {
            var kerasModel = 
                new KerasModelNet(@"G:\博士论文\钢筋混凝土柱补充试验\Python\HyperParameter\Activations-Adam\Sigmoid\0\AUDMColumnH0.model");
            //构造参数
            var paramList = new List<double>
            {
                 0.46153846200000004,0.152727273,0.89749875,0.035333333,
            };
            //完成多次预测
            int predictCount = 200000;
            //遍历
            for(int i = 0; i < predictCount; i++)
            {
                var y = kerasModel.Predict(paramList);
            }
            
        }
    }
}
